package com.yuandian.management.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuandian.api.management.entity.ConfDecrypt;
import com.yuandian.bpm.common.security.util.SecurityUtils;
import com.yuandian.management.mapper.ConfDecryptMapper;
import com.yuandian.management.service.ConfDecryptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 解密方式配置表-Service实现
 * @author zfsn
 * @date 2023-3-23
 */
@Service
public class ConfDecryptServiceImpl extends ServiceImpl<ConfDecryptMapper, ConfDecrypt>
		implements ConfDecryptService {

	@Autowired
	ConfDecryptMapper confDecryptMapper;
	/**
	 * 新增数据
	 *
	 * @param confDecrypt 实例对象
	 * @return 通用返回对象
	 */
	@Override
	public boolean save(ConfDecrypt confDecrypt) {
		confDecrypt.setCreateBy(SecurityUtils.getUser().getName());
		confDecrypt.setCreateTime(LocalDateTime.now());
		return super.save(confDecrypt);
	}

	/**
	 * 更新数据
	 *
	 * @param confDecrypt 实例对象
	 * @return 通用返回对象
	 */
	@Override
	public boolean updateById(ConfDecrypt confDecrypt) {
		confDecrypt.setUpdateBy(SecurityUtils.getUser().getName());
		confDecrypt.setUpdateTime(LocalDateTime.now());
		return super.updateById(confDecrypt);
	}

	@Override
	public List<ConfDecrypt> selectResourceCodes(List<String> list) {
		return confDecryptMapper.selectResourceCodes(list);
	}

	/**
	 * 分页查询
	 *
	 * @param confDecrypt 筛选条件
	 * @return 通用返回对象
	 */
	@Override
	public Page<ConfDecrypt> listPage(ConfDecrypt confDecrypt) {
		return confDecryptMapper.listPage(new Page<>(confDecrypt.getPageNum(), confDecrypt.getPageSize()), confDecrypt);
	}
}
